﻿namespace HuaWei.CBR.QTJL
{
    using DevExpress.Data;
    using DevExpress.XtraEditors;
    using DevExpress.XtraEditors.Controls;
    using DevExpress.XtraEditors.Repository;
    using DevExpress.XtraGrid;
    using DevExpress.XtraGrid.Columns;
    using DevExpress.XtraGrid.Views.Base;
    using DevExpress.XtraGrid.Views.Grid;
    using HuaWei.CommClass;
    using HuaWei.CommComp;
    using HuaWei.Windows.Forms;
    using System;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Windows.Forms;

    public class FrmQTKK : FrmBase
    {
        private BindingSource bindingSource;
        private SimpleButton btnAdd;
        private SimpleButton GgxUfExf5;
        private GridColumn gridColumn1;
        private GridColumn gridColumn13;
        private GridColumn gridColumn14;
        private GridColumn gridColumn2;
        private GridColumn gridColumn3;
        private GridControl gridControl1;
        private GridControl gridControl2;
        private GridView gridView1;
        private GridView gridView3;
        private GroupControl groupControl1;
        private GroupControl groupControl2;
        private GroupControl groupControl3;
        private IContainer icontainer1 = null;
        private MemoEdit memoEdit5;
        private PanelControl panelControl12;
        private RepositoryItemCheckEdit repositoryItemCheckEdit1;
        private RepositoryItemCheckEdit repositoryItemCheckEdit2;

        public FrmQTKK()
        {
            this.InitializeComponent();
        }

        private void bindingSource_PositionChanged(object sender, EventArgs e)
        {
            this.ControlFormStatus();
        }

        private void btnAdd_Click(object sender, EventArgs e)
        {
            this.method1();
        }

        public override void ControlFormStatus()
        {
            int num = Convert.ToInt16(DHelp.GetObjValue(this.bindingSource, "QRXD", true));
            if (!(DHelp.GetObjValue(this.bindingSource, "QCID", false).Equals(GParams.QCInfo.QCID) && (GParams.QCInfo.QCZT < 0)))
            {
                DevCCHelp.ControlForm(base.Controls, true, 2);
            }
            else if (!num.Equals(1))
            {
                DevCCHelp.ControlForm(base.Controls, false, 1);
                this.GgxUfExf5.Enabled = true;
            }
            else
            {
                DevCCHelp.ControlForm(base.Controls, true, 1);
                this.GgxUfExf5.Enabled = false;
            }
            if (GParams.QCInfo.QCZT >= 0)
            {
                this.btnAdd.Enabled = false;
            }
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.icontainer1 != null))
            {
                this.icontainer1.Dispose();
            }
            base.Dispose(disposing);
        }

        private void FrmQTKK_Load(object sender, EventArgs e)
        {
            this.LoadData();
        }

        private void gridView1_CellValueChanged(object sender, CellValueChangedEventArgs e)
        {
            if (e.Column.FieldName.Equals("QRXD"))
            {
                if (CHelp.ConvertInt(e.Value, 0).Equals(1))
                {
                    DevCCHelp.ControlForm(base.Controls, true, 1);
                }
                else
                {
                    DevCCHelp.ControlForm(base.Controls, false, 1);
                }
            }
        }

        private void InitializeComponent()
        {
            this.icontainer1 = new Container();
            this.bindingSource = new BindingSource(this.icontainer1);
            this.groupControl1 = new GroupControl();
            this.memoEdit5 = new MemoEdit();
            this.gridControl2 = new GridControl();
            this.gridView3 = new GridView();
            this.gridColumn13 = new GridColumn();
            this.gridColumn14 = new GridColumn();
            this.repositoryItemCheckEdit1 = new RepositoryItemCheckEdit();
            this.gridControl1 = new GridControl();
            this.gridView1 = new GridView();
            this.gridColumn1 = new GridColumn();
            this.gridColumn2 = new GridColumn();
            this.gridColumn3 = new GridColumn();
            this.repositoryItemCheckEdit2 = new RepositoryItemCheckEdit();
            this.groupControl2 = new GroupControl();
            this.groupControl3 = new GroupControl();
            this.panelControl12 = new PanelControl();
            this.GgxUfExf5 = new SimpleButton();
            this.btnAdd = new SimpleButton();
            base.ds.BeginInit();
            base.dsQuery.BeginInit();
            base.dataSets.BeginInit();
            ((ISupportInitialize)this.bindingSource).BeginInit();
            this.groupControl1.BeginInit();
            this.groupControl1.SuspendLayout();
            this.memoEdit5.Properties.BeginInit();
            this.gridControl2.BeginInit();
            this.gridView3.BeginInit();
            this.repositoryItemCheckEdit1.BeginInit();
            this.gridControl1.BeginInit();
            this.gridView1.BeginInit();
            this.repositoryItemCheckEdit2.BeginInit();
            this.groupControl2.BeginInit();
            this.groupControl2.SuspendLayout();
            this.groupControl3.BeginInit();
            this.groupControl3.SuspendLayout();
            this.panelControl12.BeginInit();
            this.panelControl12.SuspendLayout();
            base.SuspendLayout();
            this.bindingSource.DataMember = "QTJL_QTKK";
            this.bindingSource.DataSource = base.dataSets;
            this.groupControl1.Controls.Add(this.memoEdit5);
            this.groupControl1.Dock = DockStyle.Fill;
            this.groupControl1.Location = new Point(0x128, 0x1b);
            this.groupControl1.Name = "groupControl1";
            this.groupControl1.Size = new Size(0xe4, 0x151);
            this.groupControl1.TabIndex = 0x1c;
            this.groupControl1.Text = "扣款内容描述";
            this.memoEdit5.DataBindings.Add(new Binding("EditValue", this.bindingSource, "KKMS", true));
            this.memoEdit5.Dock = DockStyle.Fill;
            this.memoEdit5.Location = new Point(2, 0x17);
            this.memoEdit5.Name = "memoEdit5";
            this.memoEdit5.Size = new Size(0xe0, 0x138);
            this.memoEdit5.TabIndex = 6;
            this.gridControl2.DataSource = this.bindingSource;
            this.gridControl2.Dock = DockStyle.Fill;
            this.gridControl2.EmbeddedNavigator.Buttons.Edit.Visible = false;
            this.gridControl2.Location = new Point(2, 0x17);
            this.gridControl2.MainView = this.gridView3;
            this.gridControl2.Name = "gridControl2";
            this.gridControl2.RepositoryItems.AddRange(new RepositoryItem[] { this.repositoryItemCheckEdit1 });
            this.gridControl2.Size = new Size(240, 0x138);
            this.gridControl2.TabIndex = 0x1b;
            this.gridControl2.ViewCollection.AddRange(new DevExpress.XtraGrid.Views.Base.BaseView[] { this.gridView3 });
            this.gridView3.Columns.AddRange(new GridColumn[] { this.gridColumn13, this.gridColumn14 });
            this.gridView3.GridControl = this.gridControl2;
            this.gridView3.Name = "gridView3";
            this.gridView3.OptionsCustomization.AllowFilter = false;
            this.gridView3.OptionsCustomization.AllowSort = false;
            this.gridView3.OptionsView.ColumnAutoWidth = false;
            this.gridView3.OptionsView.ShowColumnHeaders = false;
            this.gridView3.OptionsView.ShowFooter = true;
            this.gridView3.OptionsView.ShowGroupPanel = false;
            this.gridColumn13.Caption = "期次描述";
            this.gridColumn13.FieldName = "QCMS";
            this.gridColumn13.Name = "gridColumn13";
            this.gridColumn13.SummaryItem.DisplayFormat = "截止本期末累计扣款";
            this.gridColumn13.SummaryItem.SummaryType = SummaryItemType.Custom;
            this.gridColumn13.Visible = true;
            this.gridColumn13.VisibleIndex = 0;
            this.gridColumn13.Width = 0x86;
            this.gridColumn14.Caption = "扣款";
            this.gridColumn14.FieldName = "KHGZ";
            this.gridColumn14.Name = "gridColumn14";
            this.gridColumn14.SummaryItem.SummaryType = SummaryItemType.Sum;
            this.gridColumn14.Visible = true;
            this.gridColumn14.VisibleIndex = 1;
            this.gridColumn14.Width = 0x51;
            this.repositoryItemCheckEdit1.AutoHeight = false;
            this.repositoryItemCheckEdit1.DisplayValueChecked = "1";
            this.repositoryItemCheckEdit1.DisplayValueUnchecked = "0";
            this.repositoryItemCheckEdit1.Name = "repositoryItemCheckEdit1";
            this.repositoryItemCheckEdit1.NullStyle = StyleIndeterminate.Unchecked;
            this.repositoryItemCheckEdit1.ValueChecked = 1;
            this.repositoryItemCheckEdit1.ValueUnchecked = 0;
            this.gridControl1.DataSource = this.bindingSource;
            this.gridControl1.Dock = DockStyle.Fill;
            this.gridControl1.EmbeddedNavigator.Buttons.Edit.Visible = false;
            this.gridControl1.Location = new Point(2, 0x17);
            this.gridControl1.MainView = this.gridView1;
            this.gridControl1.Name = "gridControl1";
            this.gridControl1.RepositoryItems.AddRange(new RepositoryItem[] { this.repositoryItemCheckEdit2 });
            this.gridControl1.Size = new Size(0x124, 0x138);
            this.gridControl1.TabIndex = 0x1d;
            this.gridControl1.ViewCollection.AddRange(new DevExpress.XtraGrid.Views.Base.BaseView[] { this.gridView1 });
            this.gridView1.Columns.AddRange(new GridColumn[] { this.gridColumn1, this.gridColumn2, this.gridColumn3 });
            this.gridView1.GridControl = this.gridControl1;
            this.gridView1.Name = "gridView1";
            this.gridView1.OptionsCustomization.AllowFilter = false;
            this.gridView1.OptionsCustomization.AllowSort = false;
            this.gridView1.OptionsView.ColumnAutoWidth = false;
            this.gridView1.OptionsView.ShowFooter = true;
            this.gridView1.OptionsView.ShowGroupPanel = false;
            this.gridView1.CellValueChanged += new CellValueChangedEventHandler(this.gridView1_CellValueChanged);
            this.gridColumn1.Caption = "期次描述";
            this.gridColumn1.FieldName = "QCMS";
            this.gridColumn1.Name = "gridColumn1";
            this.gridColumn1.SummaryItem.DisplayFormat = "截止本期末累计扣款";
            this.gridColumn1.SummaryItem.SummaryType = SummaryItemType.Custom;
            this.gridColumn1.Visible = true;
            this.gridColumn1.VisibleIndex = 0;
            this.gridColumn1.Width = 0x86;
            this.gridColumn2.Caption = "扣款";
            this.gridColumn2.FieldName = "KHJG";
            this.gridColumn2.Name = "gridColumn2";
            this.gridColumn2.SummaryItem.SummaryType = SummaryItemType.Sum;
            this.gridColumn2.Visible = true;
            this.gridColumn2.VisibleIndex = 1;
            this.gridColumn2.Width = 0x51;
            this.gridColumn3.Caption = "同意下达";
            this.gridColumn3.ColumnEdit = this.repositoryItemCheckEdit2;
            this.gridColumn3.FieldName = "QRXD";
            this.gridColumn3.Name = "gridColumn3";
            this.gridColumn3.Tag = "-1";
            this.gridColumn3.Visible = true;
            this.gridColumn3.VisibleIndex = 2;
            this.gridColumn3.Width = 60;
            this.repositoryItemCheckEdit2.AutoHeight = false;
            this.repositoryItemCheckEdit2.DisplayValueChecked = "1";
            this.repositoryItemCheckEdit2.DisplayValueUnchecked = "0";
            this.repositoryItemCheckEdit2.Name = "repositoryItemCheckEdit2";
            this.repositoryItemCheckEdit2.NullStyle = StyleIndeterminate.Unchecked;
            this.repositoryItemCheckEdit2.ValueChecked = 1;
            this.repositoryItemCheckEdit2.ValueUnchecked = 0;
            this.groupControl2.Controls.Add(this.gridControl1);
            this.groupControl2.Dock = DockStyle.Left;
            this.groupControl2.Location = new Point(0, 0x1b);
            this.groupControl2.Name = "groupControl2";
            this.groupControl2.Size = new Size(0x128, 0x151);
            this.groupControl2.TabIndex = 0x1d;
            this.groupControl2.Text = "扣回甲供材料预付款（元）";
            this.groupControl3.Controls.Add(this.gridControl2);
            this.groupControl3.Dock = DockStyle.Right;
            this.groupControl3.Location = new Point(0x20c, 0x1b);
            this.groupControl3.Name = "groupControl3";
            this.groupControl3.Size = new Size(0xf4, 0x151);
            this.groupControl3.TabIndex = 30;
            this.groupControl3.Text = "扣回农民工工资保证金（元）";
            this.panelControl12.Controls.Add(this.GgxUfExf5);
            this.panelControl12.Controls.Add(this.btnAdd);
            this.panelControl12.Dock = DockStyle.Top;
            this.panelControl12.Location = new Point(0, 0);
            this.panelControl12.Name = "panelControl12";
            this.panelControl12.Size = new Size(0x300, 0x1b);
            this.panelControl12.TabIndex = 0x22;
            this.GgxUfExf5.Dock = DockStyle.Left;
            this.GgxUfExf5.Location = new Point(0x56, 2);
            this.GgxUfExf5.Name = "btnDel";
            this.GgxUfExf5.Size = new Size(0x54, 0x17);
            this.GgxUfExf5.TabIndex = 6;
            this.GgxUfExf5.Tag = "";
            this.GgxUfExf5.Text = "删除当前扣款";
            this.GgxUfExf5.Click += new EventHandler(this.LfoCoObmo);
            this.btnAdd.Dock = DockStyle.Left;
            this.btnAdd.Location = new Point(2, 2);
            this.btnAdd.Name = "btnAdd";
            this.btnAdd.Size = new Size(0x54, 0x17);
            this.btnAdd.TabIndex = 5;
            this.btnAdd.Tag = "-2";
            this.btnAdd.Text = "添加当前扣款";
            this.btnAdd.Click += new EventHandler(this.btnAdd_Click);
            base.AutoScaleDimensions = new SizeF(6f, 12f);
            base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            base.ClientSize = new Size(0x300, 0x16c);
            base.Controls.Add(this.groupControl1);
            base.Controls.Add(this.groupControl2);
            base.Controls.Add(this.groupControl3);
            base.Controls.Add(this.panelControl12);
            base.Name = "FrmQTKK";
            this.Text = "其它扣款";
            base.Load += new EventHandler(this.FrmQTKK_Load);
            base.ds.EndInit();
            base.dsQuery.EndInit();
            base.dataSets.EndInit();
            ((ISupportInitialize)this.bindingSource).EndInit();
            this.groupControl1.EndInit();
            this.groupControl1.ResumeLayout(false);
            this.memoEdit5.Properties.EndInit();
            this.gridControl2.EndInit();
            this.gridView3.EndInit();
            this.repositoryItemCheckEdit1.EndInit();
            this.gridControl1.EndInit();
            this.gridView1.EndInit();
            this.repositoryItemCheckEdit2.EndInit();
            this.groupControl2.EndInit();
            this.groupControl2.ResumeLayout(false);
            this.groupControl3.EndInit();
            this.groupControl3.ResumeLayout(false);
            this.panelControl12.EndInit();
            this.panelControl12.ResumeLayout(false);
            base.ResumeLayout(false);
        }

        private void LfoCoObmo(object sender, EventArgs e)
        {
            if (MsgBox.ShowQuestion("是否删除当前计量？") == System.Windows.Forms.DialogResult.OK)
            {
                this.bindingSource.RemoveCurrent();
            }
        }

        public override void LoadedForm()
        {
            this.bindingSource.DataSource = base.ds.Tables["QTJL_QTKK"];
            this.bindingSource.PositionChanged += new EventHandler(this.bindingSource_PositionChanged);
            base.LoadedForm();
        }

        public override void LoadingData()
        {
            base.LoadingData();
            base.ds.Clear();
            string str = null;
            str = "select * from QTJL_QTKK " + Class28.smethod1() + "and qcid =" + GParams.QCInfo.QCID;
            Class39.smethod4(base.ida, base.ds, str, "QTJL_QTKK", true);
        }

        private void method1()
        {
            if (GParams.QCInfo.QCZT < 0)
            {
                string qCID = GParams.QCInfo.QCID;
                DataTable table = base.ds.Tables["QTJL_QTKK"];
                DataRow row = null;
                DataRow[] rowArray = table.Select("qcid=" + qCID);
                if (rowArray.Length == 0)
                {
                    table.TableNewRow += new DataTableNewRowEventHandler(Class28.smethod);
                    row = table.NewRow();
                    row.EndEdit();
                    table.Rows.Add(row);
                }
                else
                {
                    row = rowArray[0];
                }
                Class39.smethod2(base.ida, row, qCID, GParams._BDID);
            }
        }

        private void method2(object sender, EventArgs e)
        {
        }

        private void method3(object sender, ChangingEventArgs e)
        {
            if (e.NewValue.Equals(1))
            {
                if (!this.Check())
                {
                    e.Cancel = true;
                }
                else
                {
                    DevCCHelp.ControlForm(base.Controls, true, 1);
                }
            }
            else
            {
                DevCCHelp.ControlForm(base.Controls, false, 1);
            }
        }

        public override void Saving()
        {
            base.Saving();
            this.bindingSource.MoveFirst();
            this.bindingSource.EndEdit();
        }
    }
}

